home *** CD-ROM | disk | FTP | other *** search
/ Draw 3 / Draw 3.iso / AOL90 / COMP02.000 / %MAINDIR% / CalendarResource.dll / HTML / ACSETUP.JS < prev    next >
Encoding:
JavaScript  |  2004-11-29  |  14.1 KB  |  470 lines

  1.  
  2.     //--------------------------------------------------------------------------------------------
  3.     //      global variables
  4.     //--------------------------------------------------------------------------------------------
  5.  
  6.     var m_currentScreenName = "no-USSetting";
  7.  
  8.  
  9.     //--------------------------------------------------------------------------------------------
  10.     //      DoOnClick
  11.     //
  12.     // NB: This function usually looks at the ID of the object that generated
  13.     // the event to determine what action to perform - it's kind of a poor man's
  14.     // state machine. In order to add support for keyboard navigation (next page
  15.     // and cancel), I have added a parameter to the method call that let's the
  16.     // caller specify what ID to use as the event source. If no parameter is passed
  17.     // the actual event.srcElement.id property is still used, so this does not
  18.     // break the existing code...
  19.     //
  20.     // jc 6/00
  21.     //--------------------------------------------------------------------------------------------
  22.  
  23.     function DoOnClick(fake_id)
  24.     {
  25.         var src = window.event.srcElement;
  26.         var Dict = window.dialogArguments;    // incoming dictionary
  27.         var mainWindow = Dict.Item("kWindow");
  28.         var source_id = (fake_id == null) ? src.id : fake_id;
  29.  
  30.         //alert("DoOnClick: " + source_id);
  31.  
  32.         switch (source_id)
  33.         {
  34.  
  35.             ////////////////////////////////////////////////////////
  36.             //    we- Welcome screen for user who is online.
  37.             //    wo- Welcome screen for user who needs to go online.
  38.             ////////////////////////////////////////////////////////
  39.             case "we-next":
  40.                 mainWindow.external.CheckForServerAccount();
  41.                 break;
  42.             case "wo-next":
  43.             {
  44.                 if(mainWindow.external.InternetConnectionIsOpen())
  45.                 {
  46.                     mainWindow.external.CheckForServerAccount();
  47.                 }
  48.                 else
  49.                 {
  50.                     mainWindow.external.GoOnline();
  51.                     var Str = mainWindow.external.GetResourceString(6234);
  52.                     mainWindow.document.all("elemMessage").innerHTML = Str;
  53.  
  54.                     SetVisibleDIV("");    //    Prevent Closing() from killing the app.
  55.                     window.close();
  56.                 }
  57.                 break;
  58.             }
  59.             case "we-SelLaterBtn":
  60.             case "wo-SelLaterBtn":
  61.             {
  62.                 window.close();
  63.                 break;
  64.             }
  65.  
  66.  
  67.             ////////////////////////////////////////////////////////
  68.             //    sa- Checking for Server Account.
  69.             ////////////////////////////////////////////////////////
  70.             case "sa-Cancel":
  71.                 window.close();
  72.                 break;
  73.  
  74.  
  75.             ////////////////////////////////////////////////////////
  76.             //    rot- Screen displayed while we are synchronizing. 
  77.             ////////////////////////////////////////////////////////
  78.  
  79.             case "rot-Cancel":
  80.                 window.close();
  81.                 break;    
  82.  
  83.  
  84.             ////////////////////////////////////////////////////////
  85.             //    cp- "Setup is now complete. ...
  86.             ////////////////////////////////////////////////////////
  87.             case "cp-Start":
  88.                 window.close();
  89.                 mainWindow.external.NavigateToCalendar();
  90.                 break;
  91.             
  92.             case "cp-Cancel":
  93.                 window.close();
  94.                 break;                
  95.  
  96.  
  97.             ////////////////////////////////////////////////////////
  98.             //    nocr- "Where do you live? 
  99.             ////////////////////////////////////////////////////////
  100.             case "nocr-Cancel":
  101.                 window.close();
  102.                 break;        
  103.             case "nocr-Back":
  104.             //    SetVisibleDIV ("welcomS");
  105.                 break;    
  106.             case "nocr-Next":
  107.                 if (window.document.all("radUS").checked == true)
  108.                 {
  109.                     SetVisibleDIV ("no-USSetting");
  110.                 }
  111.                 else
  112.                 {
  113.                     SetVisibleDIV ("no-NOUSSetting");
  114.                 }
  115.                 break;
  116.  
  117.  
  118.             ////////////////////////////////////////////////////////
  119.             //    nous- Enter information for US user: 
  120.             ////////////////////////////////////////////////////////
  121.             case "nous-Cancel":
  122.                 window.close();
  123.                 break;    
  124.             case "nous-Back":
  125.             //    SetVisibleDIV ( "no-SetReg");
  126.                 break;    
  127.             case "nous-Next":
  128.             {
  129.                 var retValue = GetUSInfoFromUI (Dict);
  130.                 if (retValue)
  131.                 {
  132.                     SetVisibleDIV ("NewAcct");
  133.                     GetCallerWindow().external.CreateNewUserAccount(Dict);
  134.                 }
  135.              }    
  136.             break;
  137.  
  138.  
  139.             ////////////////////////////////////////////////////////
  140.             //    nonu- Enter information for non-US user: 
  141.             ////////////////////////////////////////////////////////
  142.             case "nonu-Cancel":
  143.                 window.close();
  144.                 break;
  145.             case "nonu-Back":
  146.             //    SetVisibleDIV ("no-SetReg");
  147.                 break;    
  148.             case "nonu-Next":
  149.             {
  150.                 var retValue = GetRegionInfoFromUI (Dict);
  151.                 if (retValue)
  152.                 {
  153.                     SetVisibleDIV ("NewAcct");
  154.                     GetCallerWindow().external.CreateNewUserAccount(Dict);
  155.                 }
  156.             }    
  157.             break;
  158.  
  159.  
  160.             ////////////////////////////////////////////////////////
  161.             //    na- Creating new account: 
  162.             ////////////////////////////////////////////////////////
  163.             case "na-Cancel":
  164.                 window.close();
  165.                 break;
  166.  
  167.         }
  168.     }
  169.  
  170.     //--------------------------------------------------------------------------------------------
  171.     //      DoOnKeyPress
  172.     //--------------------------------------------------------------------------------------------
  173.     function DoOnKeyPress ()
  174.     {
  175.         var keyF8   = 119;
  176.         if (68 == event.keyCode && event.ctrlKey && event.shiftKey)  // Ctrl-Shift-D
  177.         {
  178.             StartAccessibleVersionOfCalendar();
  179.             return;
  180.         }
  181.  
  182.         var keyEnter = 13;
  183.         var keyEsc   = 27;
  184.         var cancel_id = "";
  185.         var ok_id = "";
  186.  
  187.         if (event.keyCode != keyEsc && event.keyCode != keyEnter)
  188.             return;
  189.  
  190.         // This icky switch is used because as the visible DIVs change
  191.         // in the setup wizard, so do the IDs of the buttons. This switch
  192.         // keys off the visible DIV name to select a next or cancel button to
  193.         // 'press' when the Enter or Escape key is hit.
  194.         //
  195.         // screen                cancel                    next
  196.         // "WelcomS"            "we-SelLaterBtn"        "we-next"
  197.         // "WelcomSO"            "wo-SelLaterBtn"        "wo-next"
  198.         // "ServAcct"            "sa-Cancel"
  199.         // "ro-two"                "rot-Cancel"
  200.         // "su-complete"        "cp-Start"              "cp-Cancel"
  201.         // "no-SetReg"            "nocr-Cancel"            "nocr-Next"
  202.         // "no-USSetting"        "nous-Cancel"            "nous-Next"
  203.         // "no-NOUSSetting"        "nonu-Cancel"            "nonu-Next"
  204.         // "NewAcct"            "na-Cancel"
  205.         //
  206.         // jc 6/00
  207.  
  208.         switch(m_currentScreenName)
  209.         {
  210.         /*    case "WelcomS":
  211.                 cancel_id = "we-SelLaterBtn";
  212.                 ok_id = "we-next";
  213.                 break; */
  214.  
  215.             case "WelcomSO":
  216.                 cancel_id = "wo-SelLaterBtn";
  217.                 ok_id = "wo-next";
  218.                 break;
  219.  
  220.             case "ServAcct":
  221.                 cancel_id = "sa-Cancel";
  222.                 break;
  223.  
  224.             case "ro-two":
  225.                 cancel_id = "rot-Cancel";
  226.                 break;
  227.  
  228.             case "su-complete":
  229.                 cancel_id = "cp-Cancel";
  230.                 ok_id = "cp-Start";
  231.                 break;
  232.  
  233.             case "no-SetReg":
  234.                 cancel_id = "nocr-Cancel";
  235.                 ok_id = "nocr-Next";
  236.                 break;
  237.  
  238.             case "no-USSetting":
  239.                 cancel_id = "nous-Cancel";
  240.                 ok_id =    "nous-Next";
  241.                 break;
  242.  
  243.             case "no-NOUSSetting":
  244.                 cancel_id = "nonu-Cancel";
  245.                 ok_id = "nonu-Next";
  246.         
  247.             case "NewAcct":
  248.                 cancel_id = "na-Cancel";
  249.         }
  250.  
  251.         if (keyEnter == event.keyCode && ok_id != "")
  252.         {
  253.             DoOnClick(ok_id);
  254.         }
  255.         else if (keyEsc == event.keyCode && cancel_id != "")
  256.         {
  257.             DoOnClick(cancel_id);
  258.         }
  259.     }
  260.     //--------------------------------------------------------------------------------------------
  261.     //      GetUSInfoFromUI
  262.     //--------------------------------------------------------------------------------------------
  263.     function GetUSInfoFromUI (DictValues)
  264.     {
  265.     /*    DictValues.Item("kZipCode") = window.document.all("stZipCode").value;
  266.  
  267.         if (DictValues.Item("kZipCode").length < 5)
  268.         {
  269.             alert ("Problem with Zip Code Entry-Please make sure you enter \nvalid 5-digit zip code (numbers only). Thank you.");
  270.             return false;
  271.         } */
  272.  
  273.         DictValues.Item("kTimeZone") = window.document.all("stTimeZoneUS").value;
  274.         //DictValues.Item("kState") = window.document.all("stWState").value;
  275.         //DictValues.Item("kState") = ReplaceSpaceWithPlus(window.document.all("stWState").value);
  276.  
  277.     /*    if (window.document.all("stWState").value == "Select a state")
  278.         {
  279.             alert ("Error: Please select a state");
  280.             return false;
  281.         }   
  282.     */
  283.     //    DictValues.Item("kCity") = ReplaceSpaceWithPlus(window.document.all("stWCity").value);
  284.     //    DictValues.Item("kCity") = window.document.all("stWCity").value;
  285.     /*    if (DictValues.Item("kCity") == "")
  286.         {   
  287.             alert ("Error: Please select a city");
  288.             return false;
  289.         }
  290.     */
  291.         DictValues.Item("kState") = "";
  292.         DictValues.Item("kCity") = "";
  293.         return true;
  294.     
  295.     }
  296.     //--------------------------------------------------------------------------------------------
  297.     //      GetRegionInfoFromUI
  298.     //--------------------------------------------------------------------------------------------
  299.     function GetRegionInfoFromUI (DictValues)
  300.     {
  301.         DictValues.Item("kTimeZone") = window.document.all("stTimeZoneNoUS").value;
  302.         if (window.document.all("stWRegion").value == "Select a region" )
  303.         {
  304.             alert ("Error: Please select a region");
  305.             return false;
  306.         } 
  307.         //DictValues.Item("kState") = ReplaceSpaceWithPlus (window.document.all("stWCountry").value);
  308.         DictValues.Item("kState") = window.document.all("stWCountry").value;
  309.         if (DictValues.Item("kState") == "")
  310.         {
  311.             alert ("Error: Please select a country");
  312.             return false;
  313.         }   
  314.     
  315.         //DictValues.Item("kCity") =  ReplaceSpaceWithPlus(window.document.all("stOtherCity").value);
  316.         DictValues.Item("kCity") = window.document.all("stOtherCity").value;
  317.         if (DictValues.Item("kCity") == "")
  318.         {
  319.             alert ("Error: Please select a city");
  320.             return false;
  321.         } 
  322.         return true;
  323.     }
  324.     //--------------------------------------------------------------------------------------------
  325.     //      ReplaceSpaceWithPlus this function replace the space in string with a +
  326.     //--------------------------------------------------------------------------------------------
  327.     function ReplaceSpaceWithPlus (inStr)
  328.     {
  329.  
  330.       re = / /g;
  331.       outStr = inStr.replace(re, "+");
  332.       return(outStr);
  333.  
  334.     }
  335.     //--------------------------------------------------------------------------------------------
  336.     //      GetCallerWindow
  337.     //--------------------------------------------------------------------------------------------
  338.     function GetCallerWindow()
  339.     {
  340.         if(dialogArguments.item("kWindow"))
  341.             return  dialogArguments.item("kWindow");
  342.         else
  343.           throw (new Error (0, "Error:The opener window is not passed properly"));
  344.     }
  345.     //--------------------------------------------------------------------------------------------
  346.     //      ReplacePlusWithSpace this function replace the space in string with a +
  347.     //--------------------------------------------------------------------------------------------
  348.     function ReplacePlusWithSpace (inStr)
  349.     {
  350.       re = /[+]/g;
  351.       outStr = inStr.replace(re, " ");
  352.       return(outStr);
  353.  
  354.     }
  355.     //--------------------------------------------------------------------------------------------
  356.     //      SetVisibleDIV
  357.     //--------------------------------------------------------------------------------------------
  358.     function SetVisibleDIV (ShowW)
  359.     {
  360. //        Is try-catch block expensive? Anyway, seems overkill here.
  361. //        try
  362. //        {
  363.             var oldScreen = window.document.all(m_currentScreenName);
  364.             if (null != oldScreen)
  365.             {
  366.                 oldScreen.style.visibility = "hidden";    
  367.             }
  368.             if("" != ShowW)
  369.                 window.document.all(ShowW).style.visibility = "visible";
  370.             m_currentScreenName = ShowW;
  371. //        }
  372. //        catch(e)
  373. //        {
  374. //            alert("Error: Could not navigate to the specified screen '" + ShowW + "'");
  375. //        }
  376.     }
  377.  
  378.     //--------------------------------------------------------------------------------------------
  379.     //      Closing
  380.     //--------------------------------------------------------------------------------------------
  381.     function Closing()
  382.     {
  383.         var Dict = window.dialogArguments;    // incoming dictionary
  384.         var mainWindow = Dict.Item("kWindow");
  385.  
  386.         switch( m_currentScreenName ) {
  387.     //    case "WelcomS":
  388.         case "WelcomSO":
  389.         {
  390.             mainWindow.external.Quit();
  391.             break;
  392.         }
  393.         case "":
  394.             //    Closing dialog window so we can sign on.
  395.             break;
  396.         case "su-complete":
  397.             var Str = mainWindow.external.GetResourceString(6235);
  398.             mainWindow.document.all("elemMessage").innerHTML = Str;
  399.  
  400.             break;
  401.         default:
  402.             mainWindow.external.CancelSetup();
  403.             var Str = mainWindow.external.GetResourceString(6236);
  404.             mainWindow.document.all("elemMessage").innerHTML = Str;
  405.  
  406.             break;
  407.         }
  408.             
  409.     }
  410.  
  411.     //--------------------------------------------------------------------------------------------
  412.     //      SetupInitialScreen
  413.     //--------------------------------------------------------------------------------------------
  414.     function SetupInitialScreen()
  415.     {
  416.         var Dict = window.dialogArguments;
  417.         var mainWindow = Dict.Item("kWindow");
  418.         mainWindow.external.SetDialogTitle("AOL Calendar Setup");
  419.         var nextPanel = Dict.Item("kNextPanel");
  420.         SetVisibleDIV( nextPanel );
  421.     }
  422.  
  423.     //--------------------------------------------------------------------------------------------
  424.     //      DoAfterGoOnline
  425.     //--------------------------------------------------------------------------------------------
  426.     function DoAfterGoOnline( bServerAccountExists )
  427.     {
  428.         if( bServerAccountExists )
  429.         {
  430. //            SetVisibleDIV( "ro-One");
  431.             SetVisibleDIV( "ro-two");
  432.         }
  433.         else
  434.         {
  435.             SetVisibleDIV( "no-USSetting" ); //( "no-SetReg");
  436.         }
  437.     }
  438.  
  439.     //--------------------------------------------------------------------------------------------
  440.     //      ShowServAccount
  441.     //--------------------------------------------------------------------------------------------
  442.     function ShowServAccount()
  443.     {
  444.         var Dict = window.dialogArguments;
  445.         var mainWindow = Dict.Item("kWindow");
  446.         SetVisibleDIV ("ServAcct");
  447.     }
  448.  
  449.     //--------------------------------------------------------------------------------------------
  450.     //      SetupComplete
  451.     //--------------------------------------------------------------------------------------------
  452.     function SetupComplete()
  453.     {
  454.         SetVisibleDIV ("su-complete");
  455.     }
  456.  
  457.     //--------------------------------------------------------------------------------------------
  458.     //      SetupComplete
  459.     //--------------------------------------------------------------------------------------------
  460.     function SetupFailed()
  461.     {
  462.         var Dict = window.dialogArguments;    // incoming dictionary
  463.         var mainWindow = Dict.Item("kWindow");
  464.         var Str = mainWindow.external.GetResourceString(6237);
  465.         mainWindow.document.all("elemMessage").innerHTML = Str;
  466.  
  467.         SetVisibleDIV("");    //    Prevent Closing() from overwriting this.
  468.         window.close();
  469.     }
  470.